package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.BxSdphdmx;
import com.ruoyi.system.service.IBxSdphdmxService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 智能配货明细单Controller
 * 
 * @author ruoyi
 * @date 2025-03-22
 */
@RestController
@RequestMapping("/system/sdphdmx")
public class BxSdphdmxController extends BaseController
{
    @Autowired
    private IBxSdphdmxService bxSdphdmxService;

    /**
     * 查询智能配货明细单列表
     */
    @PreAuthorize("@ss.hasPermi('system:sdphdmx:list')")
    @GetMapping("/list")
    public TableDataInfo list(BxSdphdmx bxSdphdmx)
    {
        startPage();
        List<BxSdphdmx> list = bxSdphdmxService.selectBxSdphdmxList(bxSdphdmx);
        return getDataTable(list);
    }

    /**
     * 导出智能配货明细单列表
     */
    @PreAuthorize("@ss.hasPermi('system:sdphdmx:export')")
    @Log(title = "智能配货明细单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BxSdphdmx bxSdphdmx)
    {
        List<BxSdphdmx> list = bxSdphdmxService.selectBxSdphdmxList(bxSdphdmx);
        ExcelUtil<BxSdphdmx> util = new ExcelUtil<BxSdphdmx>(BxSdphdmx.class);
        util.exportExcel(response, list, "智能配货明细单数据");
    }

    /**
     * 获取智能配货明细单详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:sdphdmx:query')")
    @GetMapping(value = "/{mxid}")
    public AjaxResult getInfo(@PathVariable("mxid") Integer mxid)
    {
        return success(bxSdphdmxService.selectBxSdphdmxByMxid(mxid));
    }

    /**
     * 新增智能配货明细单
     */
    @PreAuthorize("@ss.hasPermi('system:sdphdmx:add')")
    @Log(title = "智能配货明细单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BxSdphdmx bxSdphdmx)
    {
        return toAjax(bxSdphdmxService.insertBxSdphdmx(bxSdphdmx));
    }

    /**
     * 修改智能配货明细单
     */
    @PreAuthorize("@ss.hasPermi('system:sdphdmx:edit')")
    @Log(title = "智能配货明细单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BxSdphdmx bxSdphdmx)
    {
        return toAjax(bxSdphdmxService.updateBxSdphdmx(bxSdphdmx));
    }

    /**
     * 删除智能配货明细单
     */
    @PreAuthorize("@ss.hasPermi('system:sdphdmx:remove')")
    @Log(title = "智能配货明细单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{mxids}")
    public AjaxResult remove(@PathVariable Integer[] mxids)
    {
        return toAjax(bxSdphdmxService.deleteBxSdphdmxByMxids(mxids));
    }
}
